package cn.bonoon.entities.interacting;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.bonoon.kernel.support.entities.AbstractPersistable;

/**
 * <pre>
 * 消息实体
 * 
 * 消息一经发出去了，就不允许再修改了
 * 
 * 消息应该设计为可以发送给一个部门所有员工、一个企业的所有员工、用户组和直接选择接收的用户
 * </pre>
 * 
 * @author jackson
 * 
 */
@Entity
@Table(name = "t_messages")
public class MessageEntity extends AbstractPersistable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7477109871942015009L;
	/**
	 * 消息发送者
	 */
	@Column(name = "C_SENDERID")
	private Long senderId;
	/**
	 * 发送者的姓名
	 */
	@Column(name = "C_SENDERNAME")
	private String senderName;

	/**
	 * <pre>
	 * 用户输入
	 * 系统消息、企业消息、部门消息、用户组消息等
	 * </pre>
	 */
	@Column(name = "C_TITLE")
	private String title;
	/**
	 * 消息内容
	 */
	@Column(name = "C_CONTENT")
	private String content;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_CREATEAT", nullable = false)
	private Date createAt;
	/**
	 * 0:系统消息 1:普通消息
	 */
	@Column(name = "C_STATUS")
	private int status;

	/**
	 * 接收者的人数
	 */
	@Column(name = "C_TOTAL")
	private int total;

	@OneToMany(mappedBy = "message", cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE })
	private List<MessageAcceptEntity> accepts;

	public Long getSenderId() {
		return senderId;
	}

	public void setSenderId(Long senderId) {
		this.senderId = senderId;
	}

	public String getSenderName() {
		return senderName;
	}

	public void setSenderName(String senderName) {
		this.senderName = senderName;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreateAt() {
		return createAt;
	}

	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public void setAccepts(List<MessageAcceptEntity> accepts) {
		this.accepts = accepts;
	}

	public List<MessageAcceptEntity> getAccepts() {
		return accepts;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

}
